#include <iostream>
#include <cstring>
using namespace std;
bool cmp(char a[],char b[]){
	int l1=strlen(a);
	int l2=strlen(b);
	if(l1>l2) return true;
	else if(l1<l2) return false;
	
	if(strcmp(a,b)>0) return true;
	return false;
}
int main(){
	int n,m;
	char maxs[105]={0},vote[105]={0};
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>vote;
		if(cmp(vote,maxs)){
			strcpy(maxs,vote);
			m=i;
		}
	}
	cout<<m<<endl<<maxs;
	return 0;
}
